[PyTorch debug] Fix issue with tp_group=None#2733
Open
pggPL wants to merge 1 commit intoNVIDIA:mainfrom
Open
Conversation
Collaborator
Author
|
/te-ci pytorch L1 |
Contributor
Greptile SummaryThis PR fixes a subtle bug in Key changes:
Confidence Score: 5/5
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["get_reduction_params(tensor_name, tp_group)"] --> B{tensor_name == 'weight'?}
B -- No --> C["skip_reduction=False<br/>reduction_group=default<br/>reduce_within_microbatch=True"]
B -- Yes --> D{weight_tensor_tp_group_reduce?}
D -- False --> E["skip_reduction=True<br/>reduce_within_microbatch=False"]
D -- True --> F{tp_group is not None?}
F -- Yes --> G["reduction_group=tp_group<br/>skip_reduction=False<br/>reduce_within_microbatch=False"]
F -- No --> H["skip_reduction=True ✅ FIXED<br/>reduce_within_microbatch=False<br/>(was: reduction_group=None → world group 🐛)"]
Last reviewed commit: c2adcaf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
If no TP is used, then
tp_size=1andtp_group=Noneinside TE modules.In the debug feature utility
get_reduction_params(), whenTEDebugState.weight_tensor_tp_group_reduce=True, we previously setreduction_group = tp_groupunconditionally. Withtp_group=None, downstream distributed collectives interpret this as the default/world group, which can cause unintended cross-rank reduction for weight stats.This PR fixes that behavior by making TP-group reduction explicit and safe:
weight_tensor_tp_group_reduce=Truebuttp_group is None, skip reduction for weight stats;weight_tensor_tp_group_reduce=Trueandtp_groupis available, reduce in that TP group;This prevents accidental world-group reductions when TP is effectively disabled (
tp_size=1/tp_group=None) while preserving the intended semantics of "reduce only within TP group" for weight tensors.Type of change
Checklist: